<?php
include_once "backend.php";
class Admin_user  extends Backend
{
    public function __construct(){
        parent::__construct();
        $this->load->model("user_model");
    }
    public function index()
    {
        if($_POST)
        {
            
        }
        else 
        {
            $this->data["view"]="admin_user/index";
            $this->data["list_data"]=$this->user_model->getListUser(); 
            $this->render_view();
        }
    }
    public function add()
    {
        if($_POST)
        { 
            $insertData=array(
               "username"=>$this->input->post("username"),
               "password"=>md5($this->input->post("password")),
               "role_id"=>$this->input->post("role_id"),
               "status"=>1,
               "create_date"=>date("Y:m:d-h:i:s"),
               "last_update"=>date("Y:m:d-h:i:s"),
               "description"=>$this->input->post("desc")
            );
            $this->db->insert("users",$insertData);
            redirect(base_url()."index.php/user_admin/");
        }
        else
        {
            $this->data["view"]="admin_user/add";
            $this->data["roles_list"]=$this->db->get("roles")->result_array(); 
            $this->render_view();
        }
    }
    public function edit($id)
    {
        if($_POST)
        {
            
        }
        else
        {
            $this->data["view"]="admin_user/add";
            $this->render_view();
        }
    }
    public function remove($id)
    {
        
    }
    public function removeMulti()
    {
        
    }
}
?>